home *** CD-ROM | disk | FTP | other *** search
/ A.C.E. 2 / ACE CD 2.iso / FILES / UTILS / AMOSPRO4.DMS / in.adf / Tutorials / AMAL / AMAL_3.AMOS / AMAL_3.amosSourceCode
Encoding:
AMOS Source Code  |  1992-09-28  |  5.0 KB  |  164 lines

  1. '*************************** 
  2. '*    AMOS Professional    * 
  3. '*                         * 
  4. '*         AMAL_3          *                 Amal Functions
  5. '*                         * 
  6. '* (c) Europress Software  * 
  7. '*                         * 
  8. '*     Ronnie Simpson      * 
  9. '*************************** 
  10. '
  11. '------------------------------------------- 
  12. ' =XM  =YM 
  13. '------------------------------------------- 
  14. 'Functions for returning the position of the mouse pointer in hardware 
  15. 'coordinates.
  16. '
  17. 'eg.        Let R0=XM       Let Y=YM 
  18. '
  19. '------------------------------------------- 
  20. ' =K1  =K2 
  21. '------------------------------------------- 
  22. 'Functions for returning the status of the mouse keys, K1 for left key and 
  23. 'K2 for the right. 
  24. 'Functions returns -1 (true) if the button has been pressed otherwise they 
  25. 'return 0 (false)
  26. '
  27. 'eg.       If K1 Jump Lable           Let R0=K1    
  28. '
  29. '------------------------------------------- 
  30. ' =J0  =J1 
  31. '------------------------------------------- 
  32. 'Functions for returning the status of the joysticks, J1 for left joystick 
  33. 'and J0 for the right. 
  34. 'Functions returns a bit pattern. (see AMOS Professional Joy instruction)
  35. 'The format of the bit pattern is as follows:- 
  36. '
  37. '            Bit 0 set    Joystick held up     
  38. '            Bit 1 set    Joystick held down     
  39. '            Bit 2 set    Joystick held left 
  40. '            Bit 3 set    Joystick held right
  41. '            Bit 4 set    fire button pressed
  42. '
  43. 'eg.       If J0=16 Jump Quit          Let R0=J1 
  44. '
  45. '------------------------------------------- 
  46. ' =Z 
  47. '------------------------------------------- 
  48. 'Function for returning a random number,if used without a parameter Z will 
  49. 'produce a random number in the range of -32767 to 32768, This can be limited
  50. 'to a set range by placing the required range number in brackets after the 
  51. 'instruction.
  52. '
  53. 'eg.     Let R0=Z(100)     (random number in the range 0-100)  
  54. '        Let RA=Z(5)+1     (random number in the range 1-6)
  55. '
  56. '
  57. '------------------------------------------- 
  58. ' =XH  =YH 
  59. '------------------------------------------- 
  60. 'Function for converting screen to hardware coordinates relative to the given
  61. 'screen number.
  62. '                  +--->screen number  
  63. '                  |  +--->coordinate to be converted
  64. '         Let X=XH(0,160)  
  65. '
  66. '         Let RY=YH(1,100) 
  67. '
  68. '------------------------------------------- 
  69. ' =XS  =YS 
  70. '------------------------------------------- 
  71. 'Function for converting hardware to screen coordinates relative to the given
  72. 'screen number.
  73. '                  +--->screen number  
  74. '                  |  +--->coordinate to be converted
  75. '         Let X=XS(0,300)  
  76. '
  77. '         Let RY=YS(1,148) 
  78. '
  79. '------------------------------------------- 
  80. ' =V 
  81. '------------------------------------------- 
  82. 'Function  to return intensity of the given sound channel, value returned  
  83. 'will be in the range of 0 to 255 allowing animation in time with music etc. 
  84. '
  85. '                  +--->sound channel number to be tested  
  86. '         Let RV=V(2)
  87. '
  88. '         Let Y=V(1) 
  89. '
  90. '------------------------------------------- 
  91. 'EXAMPLE 
  92. '------------------------------------------- 
  93. '
  94. Screen Open 0,320,200,4,Lowres : Flash Off 
  95. Palette $339,$0,$F00,$FF0 : Curs Off : Cls 0 : Hide 
  96. For N=0 To 3 : For C=0 To 3 : Colour N*4+C+16, Colour(C) : Next : Next 
  97. '
  98. Rem *** define amal program for alien balls
  99. '
  100. A$=A$+"Let R0=RA; Let R1=RB"
  101. A$=A$+"Start:Let X=X+R0;Let Y=Y+R1"
  102. A$=A$+"If X>413 Jump A;"
  103. A$=A$+"If Y>215 Jump B;"
  104. A$=A$+"If X<150 Jump A;"
  105. A$=A$+"If Y<71  Jump B;"
  106. A$=A$+"Pause Jump Start"
  107. A$=A$+"A: If R0>0 Jump C; Let R0=RA; Let X=150; Pause Jump Start"
  108. A$=A$+"C: Let R0=RB; Let X=413; Pause Jump Start"
  109. A$=A$+"B: If R1>0 Jump D; Let R1=RA; Let Y=71; Pause Jump Start"
  110. A$=A$+"D: Let R1=RB; Let Y=215; Pause Jump Start"
  111. '
  112. Rem *** amal program for player ball 
  113. '
  114. B$="Loop: Let X=XM;Let Y=YM;Pause Jump Loop"
  115. '
  116. Rem *** get a couple of sprite images
  117. '
  118. Ink 1 : Circle 10,10,7 : Ink 2 : Paint 10,10 : Get Sprite 1,3,3 To 18,18
  119. Ink 3 : Paint 10,10 : Get Sprite 2,3,3 To 18,18
  120. Cls 0 : Ink 3 : Box 20,20 To 300,180
  121. Make Mask 
  122. '
  123. Rem *** set the external amal registers RA and RB
  124. '
  125. SPEED=1 : Amreg(0)=SPEED : Amreg(1)=-SPEED
  126. '
  127. Rem *** assign computed sprites to amal channels 8-14 (alien balls)
  128. '
  129. For N=8 To 14
  130.    Sprite N,Rnd(260)+160,Rnd(140)+70,1 : Amal N,A$
  131. Next 
  132. '
  133. Rem *** assign computed sprite 15 to amal channels (player ball) 
  134. '
  135. Sprite 15,X Mouse,Y Mouse,2
  136. Limit Mouse 150,71 To 413,215
  137. Amal 15,B$
  138. '
  139. Rem *** start player movement and print out screen 
  140. '
  141. Amal On 15
  142. Pen 3 : Paper 0 : Locate 0,1 : Centre "Avoid the red balls"
  143. Pen 2 : Locate 0,12 : Centre "G E T   R E A D Y" : Wait 150 : Locate 10,12 : Cline(20)
  144. Pen 2 : Locate 17,23 : Print "SPEED=";SPEED
  145. Timer=0
  146. '
  147. Rem *** start aliens moving and loop basic part
  148. '
  149. Amal On 
  150. Do 
  151.    If Sprite Col(15)
  152.       Boom : Pen 3 : Locate 0,11 : Centre "G A M E    O V E R"
  153.       T=((SPEED-1)*800+Timer)/50
  154.       Pen 2 : Locate 0,13 : Centre "You lasted"+Str$(T)+" Seconds"
  155.       Direct 
  156.    End If 
  157.    If Timer>800
  158.       Timer=0 : Inc SPEED
  159.       Amreg(0)=SPEED : Amreg(1)=-SPEED
  160.       Locate 23,23 : Print SPEED
  161.    End If 
  162. Loop 
  163. '
  164. Direct